package org.example.manager;

import cn.hutool.http.HttpRequest;

import cn.hutool.json.JSONUtil;
import org.example.domain.SentimentResult;
import org.springframework.stereotype.Service;

@Service
public class ModelManager {

    public SentimentResult getSentiment(String message) {
        try {
            String response = HttpRequest.post("http://localhost:5000/analyze")
                    .body(message)
                    .execute()
                    .body();
            return JSONUtil.toBean(response, SentimentResult.class);
        } catch (Exception e) {
            // 根据需要处理异常
            throw new RuntimeException("情感分析服务调用失败", e);
        }
    }
}
